package com.scoy.honeymei.custem;

import android.app.Activity;
import android.content.Intent;

import com.scoy.honeymei.activity.film.CinemaListActivity;
import com.scoy.honeymei.activity.film.FilmAdsActivity;
import com.scoy.honeymei.activity.film.FilmCinemaListActivity;
import com.scoy.honeymei.activity.home.FilmList0Activity;
import com.scoy.honeymei.activity.home.Travel0Activity;
import com.scoy.honeymei.activity.home.TravelDetailActivity;
import com.scoy.honeymei.activity.home.Trip0Activity;
import com.scoy.honeymei.activity.mall.GoodsDetailActivity;
import com.scoy.honeymei.activity.mall.ShopMainActivity;
import com.scoy.honeymei.bean.BannerBean;
import com.scoy.honeymei.install.GlideImageLoader;
import com.scoy.honeymei.url.MeConstant;
import com.scoy.honeymei.utils.SPHelper;
import com.youth.banner.Banner;
import com.youth.banner.BannerConfig;
import com.youth.banner.Transformer;
import com.youth.banner.listener.OnBannerListener;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:      com.scoy.honeymei.custem
 * Description:
 * Author:         GaoZhan & Administrator
 * UpdateDate:     2021/1/7/0007$ 11:05$
 * UpdateRemark:   更新内容
 */
public class PageMe {


    /**
     * banner图
     */
    public static void initBanner(Activity mContext, Banner banner, List<BannerBean> bannerlist) {
        if (bannerlist == null) return;

        ArrayList<String> bannerimglist = new ArrayList<>();
        for (BannerBean bean : bannerlist) {
            bannerimglist.add(bean.getImage());
        }
        banner.setBannerStyle(BannerConfig.CIRCLE_INDICATOR);
        banner.setIndicatorGravity(BannerConfig.CENTER);
        banner.setImageLoader(new GlideImageLoader());
        banner.setImages(bannerimglist);
        banner.setBannerAnimation(Transformer.Default);
        banner.isAutoPlay(true);
        banner.setDelayTime(4000);
        banner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                BannerBean bannerBean = bannerlist.get(position);
                //new 跳转类型:0=不跳转,1=影视专区,2=电影详情,3=商品详情,4=商户店铺,5=旅游专区,6=旅游详情页
                //跳转位置，0=不跳转、1=电影列表、2=出行列表、3=旅游列表、4=商品列表、5=商品详情
                int type = bannerBean.getType();
                Intent intentde = new Intent();
                if (type == 0) {

                } else if (type == 1) {//影视专区
                    if (SPHelper.getInt(MeConstant.STATE_SHOW, 0) == 1) {
                        intentde.setClass(mContext, CinemaListActivity.class);
                    } else {
                        intentde.setClass(mContext, FilmAdsActivity.class);
                    }
                    mContext.startActivity(intentde);
                } else if (type == 2) {//电影详情
                    intentde.putExtra("fId", bannerBean.getGoodsid());
                    intentde.setClass(mContext, FilmCinemaListActivity.class);
                    mContext.startActivity(intentde);
                } else if (type == 3) {//商品详情
                    intentde.setClass(mContext, GoodsDetailActivity.class);
                    intentde.putExtra("goodsId", bannerBean.getGoodsid() + "");
                    mContext.startActivityForResult(intentde, 0x871);
                } else if (type == 4) {//商户店铺
                    intentde.setClass(mContext, ShopMainActivity.class);
                    intentde.putExtra("shopId", bannerBean.getGoodsid());
                    mContext.startActivity(intentde);
                } else if (type == 5) {//旅游专区
                    intentde.setClass(mContext, Travel0Activity.class);
                    mContext.startActivity(intentde);
                } else if (type == 6) {//旅游详情页
                    intentde.setClass(mContext, TravelDetailActivity.class);
                    intentde.putExtra("tid",bannerBean.getGoodsid());
                    mContext.startActivity(intentde);
                }

            }
        });
        banner.start();
    }

}
